import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
      loginManager:null
  },
  getters: {
    getManager:state => {
      let admin = state.loginManager;
      if (!admin)
      {
         admin=JSON.parse(window.localStorage.getItem("loginManager"));
         state.loginManager=admin;
      }
      return state.loginManager?state.loginManager:{}
    }
  },
  mutations: {
    setAdmin:(state,admin)=>{
      state.loginManager=admin;
      //因为刷新页面状态管理失效，所以同时放在localStorage中一份
      window.localStorage.setItem("loginManager",JSON.stringify(admin));
    }
  },
  actions: {
  },
  modules: {
  }
})
